<?php 
@session_start();

if (!isset($_SESSION['user_name']))
    header("Location: login.html");

include("../../sistema/db.php");
include "../../sistema/includes/fechas_v1.2.php";
?>

<div id="contenedor" >

    <div style="margin: 0 auto; width: 850; padding: 10px">

        <h1 class="tituloBlanco">Mis Viajes
    <!--    <a style="float:right; margin-top: -15px" title='Agregar un Cliente' href='javascript:insertar_cliente()' ><img style='cursor:pointer' src='images/add_user.png' width="32"  border='0'  ></a>-->
            &nbsp;
        </h1>


        <table cellpadding="0" cellspacing="0" border="0" class="display datatable" id="mis_viajes" width="100%">
            <thead>
                <tr>
                    <th>Viaje Id</th>
                    <th>Fecha</th>
                    <th>Hora</th>
                    <th>Desde</th>
                    <th>Hasta</th>
                    <th>Valor</th>
                </tr>
            </thead>
            <tbody>
<?php 

//for ($index = 0; $index < 15; $index++) 
$cliente_id = $_SESSION['user_id'];

$sql = "SELECT * FROM remi_viajes WHERE cliente_id = {$cliente_id} AND viaje_estado = 1 AND eliminado = 0 ORDER BY viaje_fecha DESC  ";
$result = mysql_query($sql) or trigger_error(mysql_error());
while($row = mysql_fetch_array($result)){ 
    $dia_hoy_nro = date("N", strtotime($row['viaje_fecha']));
?>

                    <tr class="odd gradeC letra">
                        <td>#<?php echo str_pad($row['viaje_id'], 5, "0", STR_PAD_LEFT); ?></td>
                        <td><?php echo $DIA_ESP[$dia_hoy_nro].", ";  ?> <?php echo fecha_formato_largo_esp($row['viaje_fecha']); ?></td>
                        <td><?php echo date_format(date_create($row['viaje_fecha']), 'H:i'); ?></td>
                        <td><?php echo strtoupper(utf8_encode($row['viaje_desde']))?></td>
                        <td><?php echo strtoupper(utf8_encode($row['viaje_hasta']))?></td>
                        
                        <td class="center">$ <?php echo number_format($row['viaje_valor'], 2, ',', '.') ?> </td>
                    </tr>
<?php } ?>	
            </tbody>
            <tfoot class="datatable_tfoot">
                <tr>
                    <th>Viaje Id</th>
                    <th>Fecha</th>
                    <th>Hora</th>
                    <th>Desde</th>
                    <th>Hasta</th>
                    <th>Valor</th>
                </tr>
            </tfoot>
        </table>

    </div>
</div>
<script>

    $(document).ready(function(){   
        var oTableMisViajes = $('#mis_viajes').dataTable({
            // "bPaginate": false,
            "bLengthChange": false,
            // "bFilter": false,
            // "bSort": false,
            // "bInfo": false,
            // "bAutoWidth": false,
            // "oSearch": {"sSearch": "4977"},
            "iDisplayLength": 10,  
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            
            "aaSorting": [[ 0, "desc" ]],            
            /*
            "aoColumns": [
                        { "bVisible": true, "bSortable": false, "bSearchable": false, "sWidth": "50px" },
                        
                        { "bVisible": true, "bSortable": true, "bSearchable": true, "sWidth": "30px" },
                        { "bVisible": true, "bSortable": true, "bSearchable": true, "sWidth": "150px" },
                        { "bVisible": true, "bSortable": true, "bSearchable": true, "sWidth": "100px" },
                        
                        { "bVisible": true, "bSortable": true, "bSearchable": true, "sWidth": "90px" },
                        { "bVisible": true, "bSortable": true, "bSearchable": true, "sWidth": "90px" },
                        
                        // { "bVisible": true, "bSortable": true, "bSearchable": true, "sWidth": "110px" },
                        //{ "bVisible": true, "bSortable": true, "bSearchable": false, "sWidth": "50px" },
                        
                        { "bVisible": true, "bSortable": true, "bSearchable": true },
                        
                        // { "bVisible": true, "bSortable": true, "bSearchable": false, "sWidth": "50px" },
                        
                        { "bVisible": true, "bSortable": true, "bSearchable": true, "sWidth": "30px" },
                        
                        { "bSortable": false, "bSearchable": false, "sWidth": "120px" }
                    ],
             */            
            "oLanguage": oLanguageGlobal
                    
        });

    });

</script>